<!DOCTYPE html>
<html>
<head>
<title></title> <@h.head />
<style type="text/css">
body {
	padding-bottom: 40px;
}

.sidebar-nav {
	padding: 9px 0;
}

@media ( max-width : 980px) {
	/* Enable use of floated navbar text */
	.navbar-text.pull-right {
		float: none;
		padding-left: 5px;
		padding-right: 5px;
	}
}
.moreimg{
	display: none;
}
select.w{
	width: auto;
}
label {
    display: initial;
    margin-bottom: 0px;
    font-size: 12px;
}
</style>
</head>
<body>
	<form action="${path}/product/save" id="fm" method="post" enctype="multipart/form-data" class="definewidth m20">
		<input type="hidden" value="${(product.id)!0}" name="id">
		<div style="text-align: center;" id="errorMsg">${msg!}</div>
		<table class="table table-bordered table-hover definewidth m10">
			<tr>
				<td width="10%" class="tableleft">产品名<span class="required">*</span></td>
				<td><input type="text" name="name" class="disabled" value="${(product.name)!}" datatype="*" nullmsg="请输入产品名！"/></td>
			</tr>
			<tr>
				<td class="tableleft">描述</td>
				<td><textarea rows="3" cols="*" name="content">${(product.content)!}</textarea></td>
			</tr>
			<tr>
				<td class="tableleft">产品类型<span class="required">*</span></td>
				<td>
					<select name="category" datatype="*">
						<#list productCategory as dict>
							<option value="${dict.id}" <#if product?? && (product.category==dict.id)>selected</#if>>${dict.name}</option>
						</#list>
					</select>
				</td>
			</tr>
			<tr>
				<td class="tableleft">用途<span class="required">*</span></td>
				<td>
					<select name="type" datatype="*">
						<#list productType as dict>
							<option value="${dict.value}" <#if product?? && (product.type==dict.value)>selected</#if>>${dict.label}</option>
						</#list>
					</select>
				</td>
			</tr>
			<tr>
				<td class="tableleft">是否推荐<span class="required">*</span></td>
				<td><select name="isTj" datatype="*">
						<option value="0" <#if product?? && (product.isTj==0)> selected</#if>>否</option>
						<option value="1" <#if product?? && (product.isTj==1)> selected</#if>>是</option>
				</select></td>
			</tr>
			<tr>
				<td class="tableleft">排序<span class="required">*</span></td>
				<td><input type="text" name="sort" value="${(product.sort)!0}" datatype="n" nullmsg="请输入排序值！"/></td>
			</tr>
			<tr>
				<td class="tableleft">
					<#if (imgLogoPath)??>
						<a target="_blank" href="${imgLogoPath!}">展示图</a>
						<input type="hidden" name="imgLogo" value="${(product.imgLogo)!}"/>
					<#else>展示图<span class="required">*</span></#if>
				</td>
				<td>
					<input type="file" name="imgLogoFile" accept="image/jpeg,image/png" <#if !(product)??>datatype="*"</#if> nullmsg="请选择展示图！"/>
					<span class="tips">推荐600*455</span>
				</td>
			</tr>
			<tr class="moreimg" imgid="${(product.imgOne)!}">
				<td class="tableleft">
					<#if (imgOnePath)??>
						<a target="_blank" href="${imgOnePath!}">详情图</a>
						<input type="hidden" name="imgOne" value="${(product.imgOne)!}"/>
						<a title="删除" class="delimg${(product.imgOne)!}" href="javascript:delImg('${(product.id)!}','${(product.imgOne)!}')">
							<img src="${path}/static/image/delete.png">
						</a>
					<#else>详情图</#if>
				</td>
				<td>
					<label title="移动端显示"><input type="checkbox" name="isMbOne" value="1" <#if (product)?? && (product.imgOne)?? && (product.isMbOne==1)>checked</#if>>移动端</label>
					<input type="file" name="imgOneFile" accept="image/jpeg,image/png"/>
					<span class="tips">推荐PC端宽度:1920, 移动端宽度:768</span>
				</td>
			</tr>
			<tr class="moreimg" imgid="${(product.imgTwo)!}">
				<td class="tableleft">
					<#if (imgTwoPath)??>
						<a target="_blank" href="${imgTwoPath!}">详情图</a>
						<input type="hidden" name="imgTwo" value="${(product.imgTwo)!}"/>
						<a title="删除" class="delimg${(product.imgTwo)!}" href="javascript:delImg('${(product.id)!}','${(product.imgTwo)!}')">
							<img src="${path}/static/image/delete.png">
						</a>
					<#else>详情图</#if>
				</td>
				<td>
					<label><input type="checkbox" name="isMbTwo" value="1" <#if (product)?? && (product.imgTwo)?? && (product.isMbTwo==1)>checked</#if>>移动端</label>
					<input type="file" name="imgTwoFile" accept="image/jpeg,image/png"/>
					<span class="tips">推荐PC端宽度:1920, 移动端宽度:768</span>
				</td>
			</tr>
			<tr class="moreimg" imgid="${(product.imgThree)!}">
				<td class="tableleft">
					<#if (imgThreePath)??>
						<a target="_blank" href="${imgThreePath!}">详情图</a>
						<input type="hidden" name="imgThree" value="${(product.imgThree)!}"/>
						<a title="删除" class="delimg${(product.imgThree)!}" href="javascript:delImg('${(product.id)!}','${(product.imgThree)!}')">
							<img src="${path}/static/image/delete.png">
						</a>
					<#else>详情图</#if>
				</td>
				<td>
					<label><input type="checkbox" name="isMbThree" value="1" <#if (product)?? && (product.imgThree)?? && (product.isMbThree==1)>checked</#if>>移动端</label>
					<input type="file" name="imgThreeFile" accept="image/jpeg,image/png"/>
					<span class="tips">推荐PC端宽度:1920, 移动端宽度:768</span>
				</td>
			</tr>
			<tr class="moreimg" imgid="${(product.imgFour)!}">
				<td class="tableleft">
					<#if (imgFourPath)??>
						<a target="_blank" href="${imgFourPath!}">详情图</a>
						<input type="hidden" name="imgFour" value="${(product.imgFour)!}"/>
						<a title="删除" class="delimg${(product.imgFour)!}" href="javascript:delImg('${(product.id)!}','${(product.imgFour)!}')">
							<img src="${path}/static/image/delete.png">
						</a>
					<#else>详情图</#if>
				</td>
				<td>
					<label><input type="checkbox" name="isMbFour" value="1" <#if (product)?? && (product.imgFour)?? && (product.isMbFour==1)>checked</#if>>移动端</label>
					<input type="file" name="imgFourFile" accept="image/jpeg,image/png"/>
					<span class="tips">推荐PC端宽度:1920, 移动端宽度:768</span>
				</td>
			</tr>
			<tr class="moreimg" imgid="${(product.imgFive)!}">
				<td class="tableleft">
					<#if (imgFivePath)??>
						<a target="_blank" href="${imgFivePath!}">详情图</a>
						<input type="hidden" name="imgFive" value="${(product.imgFive)!}"/>
						<a title="删除" class="delimg${(product.imgFive)!}" href="javascript:delImg('${(product.id)!}','${(product.imgFive)!}')">
							<img src="${path}/static/image/delete.png">
						</a>
					<#else>详情图</#if>
				</td>
				<td>
					<label><input type="checkbox" name="isMbFive" value="1" <#if (product)?? && (product.imgFive)?? && (product.isMbFive==1)>checked</#if>>移动端</label>
					<input type="file" name="imgFiveFile" accept="image/jpeg,image/png"/>
					<span class="tips">推荐PC端宽度:1920, 移动端宽度:768</span>
				</td>
			</tr>
			<tr class="moreimg" imgid="${(product.imgSix)!}">
				<td class="tableleft">
					<#if (imgSixPath)??>
						<a target="_blank" href="${imgSixPath!}">详情图</a>
						<input type="hidden" name="imgSix" value="${(product.imgSix)!}"/>
						<a title="删除" class="delimg${(product.imgSix)!}" href="javascript:delImg('${(product.id)!}','${(product.imgSix)!}')">
							<img src="${path}/static/image/delete.png">
						</a>
					<#else>详情图</#if>
				</td>
				<td>
					<label><input type="checkbox" name="isMbSix" value="1" <#if (product)?? && (product.imgSix)?? && (product.isMbSix==1)>checked</#if>>移动端</label>
					<input type="file" name="imgSixFile" accept="image/jpeg,image/png"/>
					<span class="tips">推荐PC端宽度:1920, 移动端宽度:768</span>
				</td>
			</tr>
			<tr class="moreimg" imgid="${(product.imgSeven)!}">
				<td class="tableleft">
					<#if (imgSevenPath)??>
						<a target="_blank" href="${imgSevenPath!}">详情图</a>
						<input type="hidden" name="imgSeven" value="${(product.imgSeven)!}"/>
						<a title="删除" class="delimg${(product.imgSeven)!}" href="javascript:delImg('${(product.id)!}','${(product.imgSeven)!}')">
							<img src="${path}/static/image/delete.png">
						</a>
					<#else>详情图</#if>
				</td>
				<td>
					<label><input type="checkbox" name="isMbSeven" value="1" <#if (product)?? && (product.imgSeven)?? && (product.isMbSeven==1)>checked</#if>>移动端</label>
					<input type="file" name="imgSevenFile" accept="image/jpeg,image/png"/>
					<span class="tips">推荐PC端宽度:1920, 移动端宽度:768</span>
				</td>
			</tr>
			<tr class="moreimg" imgid="${(product.imgEight)!}">
				<td class="tableleft">
					<#if (imgEightPath)??>
						<a target="_blank" href="${imgEightPath!}">详情图</a>
						<input type="hidden" name="imgEight" value="${(product.imgEight)!}"/>
						<a title="删除" class="delimg${(product.imgEight)!}" href="javascript:delImg('${(product.id)!}','${(product.imgEight)!}')">
							<img src="${path}/static/image/delete.png">
						</a>
					<#else>详情图</#if>
				</td>
				<td>
					<label><input type="checkbox" name="isMbEight" value="1" <#if (product)?? && (product.imgEight)?? && (product.isMbEight==1)>checked</#if>>移动端</label>
					<input type="file" name="imgEightFile" accept="image/jpeg,image/png"/>
					<span class="tips">推荐PC端宽度:1920, 移动端宽度:768</span>
				</td>
			</tr>
			<tr class="moreimg" imgid="${(product.imgNine)!}">
				<td class="tableleft">
					<#if (imgNinePath)??>
						<a target="_blank" href="${imgNinePath!}">详情图</a>
						<input type="hidden" name="imgNine" value="${(product.imgNine)!}"/>
						<a title="删除" class="delimg${(product.imgNine)!}" href="javascript:delImg('${(product.id)!}','${(product.imgNine)!}')">
							<img src="${path}/static/image/delete.png">
						</a>
					<#else>详情图</#if>
				</td>
				<td>
					<label><input type="checkbox" name="isMbNine" value="1" <#if (product)?? && (product.imgNine)?? && (product.isMbNine==1)>checked</#if>>移动端</label>
					<input type="file" name="imgNineFile" accept="image/jpeg,image/png"/>
					<span class="tips">推荐PC端宽度:1920, 移动端宽度:768</span>
				</td>
			</tr>
			<tr class="moreimg" imgid="${(product.imgTen)!}">
				<td class="tableleft">
					<#if (imgTenPath)??>
						<a target="_blank" href="${imgTenPath!}">详情图</a>
						<input type="hidden" name="imgTen" value="${(product.imgTen)!}"/>
						<a title="删除" class="delimg${(product.imgTen)!}" href="javascript:delImg('${(product.id)!}','${(product.imgTen)!}')">
							<img src="${path}/static/image/delete.png">
						</a>
					<#else>详情图</#if>
				</td>
				<td>
					<label><input type="checkbox" name="isMbTen" value="1" <#if (product)?? && (product.imgTen)?? && (product.isMbTen==1)>checked</#if>>移动端</label>
					<input type="file" name="imgTenFile" accept="image/jpeg,image/png"/>
					<span class="tips">推荐PC端宽度:1920, 移动端宽度:768</span>
				</td>
			</tr>
			<tr class="moreimg" imgid="${(product.imgEleven)!}">
				<td class="tableleft">
					<#if (imgElevenPath)??>
						<a target="_blank" href="${imgElevenPath!}">详情图</a>
						<input type="hidden" name="imgEleven" value="${(product.imgEleven)!}"/>
						<a title="删除" class="delimg${(product.imgEleven)!}" href="javascript:delImg('${(product.id)!}','${(product.imgEleven)!}')">
							<img src="${path}/static/image/delete.png">
						</a>
					<#else>详情图</#if>
				</td>
				<td>
					<label><input type="checkbox" name="isMbEleven" value="1" <#if (product)?? && (product.imgEleven)?? && (product.isMbEleven==1)>checked</#if>>移动端</label>
					<input type="file" name="imgElevenFile" accept="image/jpeg,image/png"/>
					<span class="tips">推荐PC端宽度:1920, 移动端宽度:768</span>
				</td>
			</tr>
			<tr class="moreimg" imgid="${(product.imgTwelve)!}">
				<td class="tableleft">
					<#if (imgTwelvePath)??>
						<a target="_blank" href="${imgTwelvePath!}">详情图</a>
						<input type="hidden" name="imgTwelve" value="${(product.imgTwelve)!}"/>
						<a title="删除" class="delimg${(product.imgTwelve)!}" href="javascript:delImg('${(product.id)!}','${(product.imgTwelve)!}')">
							<img src="${path}/static/image/delete.png">
						</a>
					<#else>详情图</#if>
				</td>
				<td>
					<label><input type="checkbox" name="isMbTwelve" value="1" <#if (product)?? && (product.imgTwelve)?? && (product.isMbTwelve==1)>checked</#if>>移动端</label>
					<input type="file" name="imgTwelveFile" accept="image/jpeg,image/png"/>
					<span class="tips">推荐PC端宽度:1920, 移动端宽度:768</span>
				</td>
			</tr>
			<tr class="moreimg" imgid="${(product.imgThirteen)!}">
				<td class="tableleft">
					<#if (imgThirteenPath)??>
						<a target="_blank" href="${imgThirteenPath!}">详情图</a>
						<input type="hidden" name="imgThirteen" value="${(product.imgThirteen)!}"/>
						<a title="删除" class="delimg${(product.imgThirteen)!}" href="javascript:delImg('${(product.id)!}','${(product.imgThirteen)!}')">
							<img src="${path}/static/image/delete.png">
						</a>
					<#else>详情图</#if>
				</td>
				<td>
					<label><input type="checkbox" name="isMbThirteen" value="1" <#if (product)?? && (product.imgThirteen)?? && (product.isMbThirteen==1)>checked</#if>>移动端</label>
					<input type="file" name="imgThirteenFile" accept="image/jpeg,image/png"/>
					<span class="tips">推荐PC端宽度:1920, 移动端宽度:768</span>
				</td>
			</tr>
			<tr class="moreimg" imgid="${(product.imgFourteen)!}">
				<td class="tableleft">
					<#if (imgFourteenPath)??>
						<a target="_blank" href="${imgFourteenPath!}">详情图</a>
						<input type="hidden" name="imgFourteen" value="${(product.imgFourteen)!}"/>
						<a title="删除" class="delimg${(product.imgFourteen)!}" href="javascript:delImg('${(product.id)!}','${(product.imgFourteen)!}')">
							<img src="${path}/static/image/delete.png">
						</a>
					<#else>详情图</#if>
				</td>
				<td>
					<label><input type="checkbox" name="isMbFourteen" value="1" <#if (product)?? && (product.imgFourteen)?? && (product.isMbFourteen==1)>checked</#if>>移动端</label>
					<input type="file" name="imgFourteenFile" accept="image/jpeg,image/png"/>
					<span class="tips">推荐PC端宽度:1920, 移动端宽度:768</span>
				</td>
			</tr>
			<tr class="moreimg" imgid="${(product.imgFifteen)!}">
				<td class="tableleft">
					<#if (imgFifteenPath)??>
						<a target="_blank" href="${imgFifteenPath!}">详情图</a>
						<input type="hidden" name="imgFifteen" value="${(product.imgFifteen)!}"/>
						<a title="删除" class="delimg${(product.imgFifteen)!}" href="javascript:delImg('${(product.id)!}','${(product.imgFifteen)!}')">
							<img src="${path}/static/image/delete.png">
						</a>
					<#else>详情图</#if>
				</td>
				<td>
					<label><input type="checkbox" name="isMbFifteen" value="1" <#if (product)?? && (product.imgFifteen)?? && (product.isMbFifteen==1)>checked</#if>>移动端</label>
					<input type="file" name="imgFifteenFile" accept="image/jpeg,image/png"/>
					<span class="tips">推荐PC端宽度:1920, 移动端宽度:768</span>
				</td>
			</tr>
			<tr class="moreimg" imgid="${(product.imgSixteen)!}">
				<td class="tableleft">
					<#if (imgSixteenPath)??>
						<a target="_blank" href="${imgSixteenPath!}">详情图</a>
						<input type="hidden" name="imgSixteen" value="${(product.imgSixteen)!}"/>
						<a title="删除" class="delimg${(product.imgSixteen)!}" href="javascript:delImg('${(product.id)!}','${(product.imgSixteen)!}')">
							<img src="${path}/static/image/delete.png">
						</a>
					<#else>详情图</#if>
				</td>
				<td>
					<label><input type="checkbox" name="isMbSixteen" value="1" <#if (product)?? && (product.imgSixteen)?? && (product.isMbSixteen==1)>checked</#if>>移动端</label>
					<input type="file" name="imgSixteenFile" accept="image/jpeg,image/png"/>
					<span class="tips">推荐PC端宽度:1920, 移动端宽度:768</span>
				</td>
			</tr>
			<tr class="moreimg" imgid="${(product.imgSeventeen)!}">
				<td class="tableleft">
					<#if (imgSeventeenPath)??>
						<a target="_blank" href="${imgSeventeenPath!}">详情图</a>
						<input type="hidden" name="imgSeventeen" value="${(product.imgSeventeen)!}"/>
						<a title="删除" class="delimg${(product.imgSeventeen)!}" href="javascript:delImg('${(product.id)!}','${(product.imgSeventeen)!}')">
							<img src="${path}/static/image/delete.png">
						</a>
					<#else>详情图</#if>
				</td>
				<td>
					<label><input type="checkbox" name="isMbSeventeen" value="1" <#if (product)?? && (product.imgSeventeen)?? && (product.isMbSeventeen==1)>checked</#if>>移动端</label>
					<input type="file" name="imgSeventeenFile" accept="image/jpeg,image/png"/>
					<span class="tips">推荐PC端宽度:1920, 移动端宽度:768</span>
				</td>
			</tr>
			<tr class="moreimg" imgid="${(product.imgEighteen)!}">
				<td class="tableleft">
					<#if (imgEighteenPath)??>
						<a target="_blank" href="${imgEighteenPath!}">详情图</a>
						<input type="hidden" name="imgEighteen" value="${(product.imgEighteen)!}"/>
						<a title="删除" class="delimg${(product.imgEighteen)!}" href="javascript:delImg('${(product.id)!}','${(product.imgEighteen)!}')">
							<img src="${path}/static/image/delete.png">
						</a>
					<#else>详情图</#if>
				</td>
				<td>
					<label><input type="checkbox" name="isMbEighteen" value="1" <#if (product)?? && (product.imgEighteen)?? && (product.isMbEighteen==1)>checked</#if>>移动端</label>
					<input type="file" name="imgEighteenFile" accept="image/jpeg,image/png"/>
					<span class="tips">推荐PC端宽度:1920, 移动端宽度:768</span>
				</td>
			</tr>
			<tr class="moreimg" imgid="${(product.imgNineteen)!}">
				<td class="tableleft">
					<#if (imgNineteenPath)??>
						<a target="_blank" href="${imgNineteenPath!}">详情图</a>
						<input type="hidden" name="imgNineteen" value="${(product.imgNineteen)!}"/>
						<a title="删除" class="delimg${(product.imgNineteen)!}" href="javascript:delImg('${(product.id)!}','${(product.imgNineteen)!}')">
							<img src="${path}/static/image/delete.png">
						</a>
					<#else>详情图</#if>
				</td>
				<td>
					<label><input type="checkbox" name="isMbNineteen" value="1" <#if (product)?? && (product.imgNineteen)?? && (product.isMbNineteen==1)>checked</#if>>移动端</label>
					<input type="file" name="imgNineteenFile" accept="image/jpeg,image/png"/>
					<span class="tips">推荐PC端宽度:1920, 移动端宽度:768</span>
				</td>
			</tr>
			<tr class="moreimg" imgid="${(product.imgTwenty)!}">
				<td class="tableleft">
					<#if (imgTwentyPath)??>
						<a target="_blank" href="${imgTwentyPath!}">详情图</a>
						<input type="hidden" name="imgTwenty" value="${(product.imgTwenty)!}"/>
						<a title="删除" class="delimg${(product.imgTwenty)!}" href="javascript:delImg('${(product.id)!}','${(product.imgTwenty)!}')">
							<img src="${path}/static/image/delete.png">
						</a>
					<#else>详情图</#if>
				</td>
				<td>
					<label><input type="checkbox" name="isMbTwenty" value="1" <#if (product)?? && (product.imgTwenty)?? && (product.isMbTwenty==1)>checked</#if>>移动端</label>
					<input type="file" name="imgTwentyFile" accept="image/jpeg,image/png"/>
					<span class="tips">推荐PC端宽度:1920, 移动端宽度:768</span>
				</td>
			</tr>
			<tr>
				<td class="tableleft">
					<a title="添加" id="addImg" href="javascript:void(0)"><img src="${path}/static/image/add.png">添加详情图</a>
				</td>
				<td>
					<button type="submit" class="btn btn-primary" type="button">保存</button>
					&nbsp;&nbsp;
					<button type="button" class="btn btn-success" name="backid"
						id="backid">返回列表</button>
				</td>
			</tr>
		</table>
	</form>
	<@h.foot />
<script type="text/javascript">
	$(function() {
		$('#backid').click(function() {
			window.location.href = "${path}/product/list";
		});
		$(".moreimg").each(function(){
			if ($(this).attr("imgId") != ""){
				$(this).removeClass("moreimg");
			}
		});
		$('#addImg').click(function() {
			$(".moreimg :first").removeClass("moreimg");
			document.body.scrollTop=document.body.scrollHeight;
			if ($(".moreimg").length == 0){
				$(this).hide();
			}
		});
	});
	$("#fm").Validform({
		tiptype : 3,
		postonce : true,
		beforeSubmit : function() {
			$("input[type=checkbox]").each(function(index, obj) {
				if(!$(obj).attr("checked")){
					$(obj).attr("checked", true);
					$(obj).attr("value", 0);
				}
			});
		}
	});
	function delImg(id,fileId) {
		$.ajax({type:"post",
			   url : "${path}/product/deleteImg",
			   data : {'id':id,'fileId':fileId},
			   dataType : "json",
			   success : function(result){
				   if (result.status == 0) {
					   $(".delimg" + fileId).parent().html($(".delimg" + fileId).parent().text());
				   } else {
					   alert(result.msg);
				   }
			   }
		});
	}
</script>
</body>
</html>